export let nickname = {
  namespaced: true,
  state: {
    nickname_data: {}
  },
  actions: {
    getNickNameData(store, data = {}) {
      let url = "/activate/init/profile?nickname="+data.nickname;
      return new Promise((resolve, reject) => {
        axios.get(url).then(({
          data
        }) => {
          store.commit('setNickNameData', data);
          resolve(data);
        }).catch((error) => {
          if (error.response) {
            // 请求已发出，但服务器响应的状态码不在 2xx 范围内
            reject(error.response.data)
          }
        });
      });
    }
  },
  mutations: {
    setNickNameData(state, data = {}) {
      state.nickname_data = data;
    }
  }
}
